#include"threadPool.h"
#include"thread.h"

ThreadPool::ThreadPool(int numOfthread):numberOfThreads_(numOfthread)
{
  for(int i=0;i< numberOfThreads_;++i)
  {
     pool_.push_back(new Thread());
  }
}
ThreadPool::~ThreadPool()
{
  for(int i= numberOfThreads_ - 1;i>=0;--i)
  {
    delete pool_[i];
    pool_.pop_back();
  }
}

int ThreadPool::GetNumberOfThreads()const
{
  return numberOfThreads_;
}

int ThreadPool::GetSubThreadSocketPairFirst()const
{
     static int robin =0;                       
     return pool_[robin++ % numberOfThreads_]->GetSocketPairFirst();
}